package com.itlong.cloud.enumerate;

/**
 * <desc>
 *      通行记录开门方式枚举
 * </desc>
 *
 * @createDate 2017-09-22
 */
public enum OpenTypeEnum {

    BY_SHOT("点击", 1),
    BY_AUTO_INDUCTION("自动感应", 2),
    BY_SHAKE("摇一摇", 3),
    BY_PHONE("电话开门", 4),
    BY_VISTOR("访客开门", 5),
    BY_OWN("自主开门", 6),
    BY_PASSWORD("密码开门", 7),

    BY_QRCODE("二维码", 8),
    BY_CARD("刷卡", 9),
    BY_DYNAMIC_PASSWORD("动态密码", 10),
    BY_VISTOR_QRCODE("访客二维码",11),
    BY_FACE_RECOGNITION("人脸识别",12),
    BY_IOT_RECOGNITION("App网络开门",13),
    BY_VISITOR_FACE("访客人脸开门",14),
    BY_IDCARD_KEY("身份证开门",15),
    BY_SMART_CARD("一卡通开门",16),
    BY_ADVANCED_QR_CODE("高级用户二维码开门",17),
    BY_VISITOR_IDCARD_KEY("访客身份证开门",18),
    UNKOWNTYPE("未知开门方式", -1),
    CALL_ELEVATOR("预约呼梯",19),
    BLUETOOTH_IOT("蓝牙+IOT",20),
    ;
    private String description;
    private Integer type;

    /**
     * <desc>
     *      通行记录开门方式枚举无参构造函数
     * </desc>
     * @param
     * @return
     * @author Biao.R
     * @createDate 2017/10/13
     */
    OpenTypeEnum() {
    }

    /**
     * <desc>
     *      通行记录开门方式枚举描述与类型构造函数
     * </desc>
     * @param description 描述
     * @param type 类型
     * @return
     * @author Biao.R
     * @createDate 2017/10/13
     */
    OpenTypeEnum(String description, Integer type) {
        this.type = type;
        this.description = description;
    }

    /**
     * <desc>
     *      获取通行记录开门方式枚举描述
     * </desc>
     * @param
     * @return String
     * @author Biao.R
     * @createDate 2017/10/13
     */
    public String getDescription() {
        return description;
    }

    /**
     * <desc>
     *      获取通行记录开门方式枚举类型
     * </desc>
     * @param
     * @return Integer
     * @author Biao.R
     * @createDate 2017/10/13
     */
    public Integer getType() {
        return type;
    }

    /**
     * <desc>
     *      获取枚举的描述
     * </desc>
     * @param type 枚举类型
     * @return 枚举描述
     * @author Biao.R
     * @createDate 2017/10/13
     */
    public static String getDescription(Integer type){
        if (type == null) {
            return "";
        }
        OpenTypeEnum[] types = OpenTypeEnum.values();
        for(OpenTypeEnum limitCategory : types ){
            if(limitCategory.getType().equals(type)){
                return limitCategory.getDescription();
            }
        }
        return "";
    }

    /**
     * <desc>
     *      根据设备类型获取设备类型的枚举
     * </desc>
     * @param openType 枚举类型
     * @return 枚举描述
     * @author Biao.R
     * @createDate 2017/10/13
     */
    public static OpenTypeEnum getByOpenType(Integer openType){
        for (OpenTypeEnum value : values()) {
            if (value.getType().equals(openType)) {
                return value;
            }
        }
        return UNKOWNTYPE;
    }
}
